#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

struct Node{
    int l, r;
    double sumsin, sumcos;
    LL add;
}node[N * 4];

int n, m;
int q[N];

void pushup(int u){
    node[u].sumsin = node[u << 1].sumsin + node[u << 1 | 1].sumsin;
    node[u].sumcos = node[u << 1].sumcos + node[u << 1 | 1].sumcos;
}

void update(Node& nod, double COS, double SIN){
    double sinn = nod.sumsin, coss = nod.sumcos;
    nod.sumsin = sinn * COS + coss * SIN;
    nod.sumcos = coss * COS - sinn * SIN;

}

void pushdown(Node& root, Node& left, Node& right){
    if(root.add){
        double COS = cos(root.add), SIN  = sin(root.add);
        left.add += root.add;
        right.add += root.add;
        update(left, COS, SIN);
        update(right, COS, SIN);
        root.add = 0;
    }
}

void pushdown(int u){
    pushdown(node[u], node[u << 1], node[u << 1 | 1]);
}


void build(int u, int l, int r){
    node[u].l = l, node[u].r = r, node[u].add = 0;
    if(l == r){
        node[u].sumsin = sin(q[l]);
        node[u].sumcos = cos(q[l]);
        return;
    }

    int mid = l + r >> 1;
    build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
    pushup(u);
}

void modify(int u, int l, int r, int k){
    if(node[u].l >= l && node[u].r <= r){
        update(node[u], cos(k), sin(k));
        node[u].add += k;
    }else{
        pushdown(u);
        int mid = (node[u].l + node[u].r) >> 1;
        if(l <= mid) modify(u << 1, l, r, k);
        if(r > mid) modify(u << 1 | 1, l, r, k);
        pushup(u);
    }
}

double query(int u, int l, int r){
    if(node[u].l >= l && node[u].r <= r){
        return node[u].sumsin;
    }else{
        pushdown(u);
        int mid = (node[u].l + node[u].r) >> 1;
        double res = 0;
        if(l <= mid) res += query(u << 1, l, r);
        if(r > mid) res += query(u << 1 | 1, l, r);
        return res;
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d", &n);
    for(int i = 1; i <= n; i ++) scanf("%d", &q[i]);

    build(1, 1, n);

    scanf("%d", &m);
    int op, l, r, v;
    while(m --){
        scanf("%d", &op);
        if(op == 1){
            scanf("%d%d%d", &l, &r, &v);
            modify(1, l, r, v);
        }else{
            scanf("%d%d", &l, &r);
            double res = query(1, l, r);
            printf("%.1f\n", res);
        }
    }

    return 0;


}
